package com.example.jerry.test;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.Toast;

import com.example.loginandpaytools.LoginAndPayToolSDK;
import com.example.loginandpaytools.ui.floatingbutton.FloatingButtonContract;
import com.example.loginandpaytools.ui.floatingbutton.MyFabMenu;

public class FabButtonActivity extends AppCompatActivity {

    MyFabMenu mFabMenu;
    Button ifOpenFab_btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_fab_button);

        mFabMenu = (MyFabMenu) findViewById(R.id.my_fab_menu);

        ifOpenFab_btn = (Button) findViewById(R.id.ifopenfab_btn);

        ifOpenFab_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LoginAndPayToolSDK.openFabButton(FabButtonActivity.this, new FloatingButtonContract.View() {

                    @Override
                    public void ifOpenFab(boolean ifOpen) {
                        openFab(ifOpen);
                    }

                    @Override
                    public void errorReturn(String errMsg) {
                        error(errMsg);
                    }
                });

            }
        });

    }

    public void openFab(boolean ifOpen) {
        Toast.makeText(this, "" + ifOpen, Toast.LENGTH_SHORT).show();
        if (ifOpen) {
            mFabMenu.setVisiable();
        }
    }

    public void error(String errMsg) {
        Toast.makeText(this, errMsg, Toast.LENGTH_SHORT).show();
    }

}
